﻿using MiniFox.Resources;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;

namespace Sys.Core.Models.Dto
{
    public class ApplicationDto
    {
        [Key]
        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [StringLength(20, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        [JsonProperty("appId")]
        public string ApplicationID { get; set; }

        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [StringLength(20, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        [JsonProperty("appName")]
        public string? ApplicationName { get; set; }

        [StringLength(50, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        [RegularExpression(MiniFox.Utility.StringExtensions.PATTERN_HOSTNAME, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonUnmatchRegex")]
        [JsonProperty("domain")]
        public string? ApplicationDomain { get; set; }

        [StringLength(200, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        [JsonProperty("path")]
        public string? ApplicationPath { get; set; }

        [StringLength(5, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        [RegularExpression(MiniFox.Utility.StringExtensions.PATTERN_UNS_NUMERIC, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonUnmatchRegex")]
        [Range(typeof(int), "80", "65535", ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRange")]
        [JsonProperty("port")]
        public string? PortNumber { get; set; }

        [JsonProperty("ssl")]
        public bool? RequireSSL { get; set; }

        [StringLength(200, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        [JsonProperty("icon")]
        public string? Icon { get; set; }
    }
}
